/*
package com.jymj.controller;

import com.jymj.entity.RtRaiseEntity;
import com.jymj.service.RtRaiseService;
import com.jymj.utils.ParseUtils;
import com.jymj.utils.R;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

*/
/**
 * Created by dl on 2017/10/18. 资金计划
 *//*

@RestController
@RequestMapping("/raise")
@Transactional(rollbackFor = Exception.class)
public class RtRaiseController {

    @Autowired
    private RtRaiseService rtRaiseService;

    ParseUtils parseUtils = new ParseUtils();

    */
/**
     * 筹资计划表
     *
     * @param pid
     * @return
     * @throws Exception
     *
     *//*

    @RequestMapping("/raise/{pid}")
    public R raise(@PathVariable("pid") Integer pid) throws Exception {
        Map<String, Object> map = new HashedMap();
        map.put("pid", pid);
        List<RtRaiseEntity> rtRaiseTasks = rtRaiseService.queryList(map);
        List<RtRaiseEntity> treeList = this.getTreeOrgs(rtRaiseTasks);
        return R.ok().put("data", treeList);
    }

    */
/**
     * 添加 修改
     *
     * @param rtRaiseEntity
     * @return
     *//*

    @RequestMapping("/save")
    public R save(@RequestBody RtRaiseEntity rtRaiseEntity) {
        if (rtRaiseEntity.getPid() != null && rtRaiseEntity.getTaskid() != null) {
            if (rtRaiseEntity.getId() == null) {
                rtRaiseService.save(rtRaiseEntity);
            } else {
                rtRaiseService.update(rtRaiseEntity);
            }
            rtRaiseService.updateParentCost(rtRaiseEntity);
        }
        return R.ok();
    }

    public List<RtRaiseEntity> getTreeOrgs(List<RtRaiseEntity> allOrgs) throws Exception {
        List<RtRaiseEntity> listParentRecord = new ArrayList<RtRaiseEntity>();
        List<RtRaiseEntity> listNotParentRecord = new ArrayList<RtRaiseEntity>();
        // 第一步：遍历allOrgs找出所有的根节点和非根节点
        if (allOrgs != null && allOrgs.size() > 0) {
            for (RtRaiseEntity org : allOrgs) {
                if (0 == org.getParentid()) {
                    listParentRecord.add(org);
                } else {
                    listNotParentRecord.add(org);
                }
            }
        }
        // 第二步： 递归获取所有子节点
        if (listParentRecord.size() > 0) {
            for (RtRaiseEntity record : listParentRecord) {
                // 添加所有子级
                record.setChildren(this.getChildOrgs(listNotParentRecord, record.getItemid()));
            }
        }
        return listParentRecord;
    }
    public List<RtRaiseEntity> getChildOrgs(List<RtRaiseEntity> childList, Integer fatherid) throws Exception {
        List<RtRaiseEntity> listParentOrgs = new ArrayList<RtRaiseEntity>();
        List<RtRaiseEntity> listNotParentOrgs = new ArrayList<RtRaiseEntity>();
        // 遍历childList，找出所有的根节点和非根节点
        if (childList != null && childList.size() > 0) {
            for (RtRaiseEntity record : childList) {
                // 对比找出父节点
                if (record.getParentid().equals(fatherid)) {
                    listParentOrgs.add(record);
                } else {
                    listNotParentOrgs.add(record);
                }
            }
        }
        // 查询子节点
        if (listParentOrgs.size() > 0) {
            for (RtRaiseEntity record : listParentOrgs) {
                // 递归查询子节点
                record.setChildren(getChildOrgs(listNotParentOrgs, record.getItemid()));
            }
        }
        return listParentOrgs;
    }
}
*/
